<template>
  <div>
       <NavHead>
      <template v-slot:iconfont-left>
        <i class="iconfont icon-arrowLeft arrow" @click="$router.back()"></i>
      </template>
      <template v-slot:title>
        <p class="names">卧室储物</p>
      </template>
      <template v-slot:iconfont-right >
        <i class="iconfont icon-caidan point" ></i>
      </template>
    </NavHead>
    <ShopTabs  class="tabs-box" :titleData="titleData2" @typeData="getTypeData">
      <template v-slot:content1>
       <div class="list1">
        <div class="pic1" v-for="(item,index) in list" :key="index">
          <img :src="item.img" alt="" />
          <p class="names">{{item.title}}</p>
          <p class="desc">{{item.desc}}</p>
          <p class="price">¥ {{item.price}}</p>
        </div>
      </div>
      </template>
      <template v-slot:content2>
       <div class="list1">
        <div class="pic1" v-for="(item,index) in list" :key="index">
          <img :src="item.img" alt="" />
          <p class="names">{{item.title}}</p>
          <p class="desc">{{item.desc}}</p>
          <p class="price">¥ {{item.price}}</p>
        </div>
      </div>
      </template>
      <template v-slot:content3>
       <div class="list1">
        <div class="pic1" v-for="(item,index) in list" :key="index">
          <img :src="item.img" alt="" />
          <p class="names">{{item.title}}</p>
          <p class="desc">{{item.desc}}</p>
          <p class="price">¥ {{item.price}}</p>
        </div>
      </div>
      </template>
    </ShopTabs>    
      
  </div>
</template>

<script>
import NavHead from "../../components/NavHead";
import ShopTabs from "./shopTabs/ShopTabs";
import api from '../../api'

export default {
    name:'RoomStorage',
    components:{
        NavHead,
        ShopTabs
    },
    props:{
        type:{
          data:String,
          default:'销量优先'
        }
    },
     data() {
    return {
      titleData2: ["销量优先", "价格高低", "综合排序"],
      list:[]
    };
  },
  mounted(){
    console.log(this.type);
    api.getRoomStorage({
      type:this.type
    }).then(res => {
      // console.log(res.data);
      this.list=res.data.list
    })
  },
  methods:{
    getTypeData(type){
      console.log(type);
      api.getRoomStorage({
        type:this.type
      }).then(res => {
        console.log(res.data);
        this.list=res.data.list
      })
    }
  }
}
</script>

<style>
.arrow {
  color: #fff;
  margin-top: 0.3rem;
}
.point {
  color: #fff;
  font-size: 0.58rem;
}
.names {
  color: #fff;
  font-size: 0.4rem;
}

.tabs-box{
    margin-top: 1.2rem;
}
.list1 {
  display: flex;
  flex-wrap: wrap;
  height: 4rem;
  width: 98%;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0.1rem;
}
.list1 .pic1 {
  width: 47%;
  margin: 0.1rem;
  box-sizing: border-box;
  background-color: #fff;
}
.list1 .pic1:nth-child(2n + 1) {
  margin-left: 0;
}
.list1 .pic1:nth-child(2n) {
  margin-left: 0.15rem;
}

.list1 .pic1 img {
  width: 100%;
  height: 2.8rem;
}
.list1 .pic1 .names {
  font-size: 0.26rem;
  color: black;
  text-align: left;
  padding: 0 0.3rem;
}
.list1 .pic1 .price {
  font-size: 0.2rem;
  color: red;
  text-align: left;
  padding: 0 0.3rem;
}
.list1 .pic1 .desc{
  font-size: 0.2rem;
  color: grey;
  text-align: left;
  padding: 0 0.3rem;
}
</style>